Programa para el circuito transmisor con teclado matricial:

Symbol T9600 = 2 ' Dato verdadero (Driven True)

TRISD = %01111000 ' Configuracin de Puerto D

TECLA VAR Byte ' Declaracin de variable "Tecla"

Pause 200 ' Pausa de 200 milisegundos para la LCD

LCDOut $fe, 1 ' Limpia la LCD

inicio:

Call teclado ' Llama a rutina de barrido de teclas.

If tecla = 0 Then inicio ' Si TECLA = 0 ninguna tecla fue

' presionada y salta de nuevo a
' la etiqueta inicio.

SerOut PORTB.0, T9600, [%10011001] ' Enva cdigo de confirmacin.

PAUSE 200

SerOut PORTB.0, T9600, [TECLA] ' Enva dato por RB0

PAUSE 300 ' Pausa de 300 milisegundos

LCDOUT $fe, 2,"Dato: ",#TECLA," " ' Muestra dato por la LCD

GoTo inicio ' Salto a inicio

teclado:

tecla = 0
PORTD.0 = 0 ' Columna 1 = 0
PORTD.1 = 1 ' Columna 2 = 1
PORTD.2 = 1 ' Columna 3 = 1
If PORTD.3 = 0 Then TECLA = 1 ' tecla "1"
If PORTD.4 = 0 Then TECLA = 4 ' tecla "4"
If PORTD.5 = 0 Then TECLA = 7 ' tecla "7"
If PORTD.6 = 0 Then TECLA = 10 ' tecla "*"
PORTD.0 = 1 ' Columna 1 = 1
PORTD.1 = 0 ' Columna 2 = 0
PORTD.2 = 1 ' Columna 3 = 1
If PORTD.3 = 0 Then TECLA = 2 ' tecla "2"
If PORTD.4 = 0 Then TECLA = 5 ' tecla "5"
If PORTD.5 = 0 Then TECLA = 8 ' tecla "8"
308
If PORTD.6 = 0 Then TECLA = 11 ' tecla "0"
PORTD.0 = 1 ' Columna 1 = 1
PORTD.1 = 1 ' Columna 2 = 1
PORTD.2 = 0 ' Columna 3 = 0
If PORTD.3 = 0 Then TECLA = 3 ' tecla "3"
If PORTD.4 = 0 Then TECLA = 6 ' tecla "6"
If PORTD.5 = 0 Then TECLA = 9 ' tecla "9"
If PORTD.6 = 0 Then TECLA = 12 ' tecla "#"
Return
End